/*
 * @Author: Liu
 * @Date: 2023-05-11 17:27:31
 * @LastEditTime: 2023-05-19 23:31:28
 */
import {
  defineConfig,
  loadEnv
} from 'vite'
import vue from '@vitejs/plugin-vue'
import pxtovw from 'postcss-px-to-viewport'
const loder_pxtovw = pxtovw({

  viewportWidth: 750,
  viewportUnit: 'vw'
})
import Components from 'unplugin-vue-components/vite';
import { VantResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default ({ mode }) => defineConfig({
  plugins: [vue(), Components({
    resolvers: [VantResolver()],
  }),],
  base: loadEnv(mode, process.cwd()).VITE_PUBLIC,
  server: {
    host: '0.0.0.0',
    cors: true,
    proxy:{
      // https://i.maoyan.com
      '/chess1025api':{
        // target:'http://192.168.254.34:8888',//替换的服务端地址
        target:'https://koc.varwey.com',//替换的服务端地址
        changeOrigin:true,//开启代理，允许跨域
        // rewrite: (path) => path.replace(/^\/api/, '') // 设置重写的路径
      }
    }
  },
  css: {
    postcss: {
      plugins: [loder_pxtovw]
    }
  },
})